<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Ttc\Model;
use Think\Model;

/**
 * 用户模型
 * @author 麦当苗儿 <zuojiazi@vip.qq.com>
 */

class ActiveContactModel extends Model {

    public $sx_data = array();

    protected $_validate = array(

    );

    protected $_auto = array (


    );

    /**
     * 修改实名状态
     */
    public function saveIdenState($condition,$state){
        $data['is_identity'] = $state;
        
        $res = $this->where($condition)->save($data);
        // var_dump($res);
        return $res;

    }
    /**
     * 查询单条用户信息
     */
    public function getAcontactInfo($condition, $field = '*') {
        return $this->field($field)->where($condition)->find();
    }

    /**
     * 注册
     */
    public function addMember(){
        if (!$this->create($this->sx_data,5)){
            $res['msg'] = $this->getError();
            $res['sta'] = -1;
            return $res;
        }else{
            $res = $this->add();
            return $res;
        }

    }

    /**
     * 登录
     */
    public function saveMember(){
        $id = $this->sx_data['id'];
        $this->create($this->sx_data,6);
        $res = $this->save();

        //登录次数加1
        if($res){
            $res = $this->where('id='.$id)->setInc('login',1);
            return $res;
        }else{
            return false;
        }

    }    

}
